home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d16 / winsrc.arc / DIALOG2.C < prev    next >
C/C++ Source or Header  |  1991-06-16  |  40KB  |  1,171 lines

  1. /*
  2.  
  3.     various dialog-box code - more in DIALOG.C
  4.  
  5. */
  6.  
  7. #include "windows.h"
  8. #include "winfract.h"
  9. #include "fractint.h"
  10. #include <math.h>
  11. #include <stdio.h>
  12. #include "profile.h"
  13.  
  14. extern HWND hwnd;                               /* handle to main window */
  15. extern char szHelpFileName[];                   /* Help file name*/
  16.  
  17. extern BOOL zoomflag;                /* TRUE is a zoom-box selected */
  18.  
  19. extern char *win_choices[];
  20. extern int win_numchoices, win_choicemade;
  21. int CurrentFractal;
  22.  
  23. extern HANDLE hDibInfo;        /* handle to the Device-independent bitmap */
  24. extern LPBITMAPINFO pDibInfo;        /* pointer to the DIB info */
  25.  
  26. extern int time_to_restart;                               /* time to restart?  */
  27. extern int time_to_reinit;                /* time to reinit? */
  28. extern int time_to_cycle;                               /* time to cycle? */
  29.  
  30. extern int xdots, ydots, colors, maxiter;
  31. extern int ytop, ybottom, xleft, xright;
  32. extern double xxmin, xxmax, yymin, yymax;
  33. extern int fractype;
  34. extern int calc_status;
  35. extern double param[4];
  36.  
  37. extern int inside, outside, biomorph, decomp, debugflag;
  38. extern int usr_stdcalcmode, usr_floatflag;
  39. extern    int    invert;     /* non-zero if inversion active */
  40. extern    double    inversion[3];    /* radius, xcenter, ycenter */
  41.  
  42. int tempfractype;
  43. int tempcolors;
  44. char tempstdcalcmode, tempfloatflag;
  45.  
  46. int numparams,numtrig;
  47. static char *trg[] = {"First Function","Second Function",
  48.               "Third Function","Fourth Function"};
  49. static int paramt[] = {ID_FRACPARTX1, ID_FRACPARTX2,
  50.                        ID_FRACPARTX3, ID_FRACPARTX4 };
  51. static int paramv[] = {ID_FRACPARAM1, ID_FRACPARAM2,
  52.                        ID_FRACPARAM3, ID_FRACPARAM4, };
  53.  
  54. extern int win_release;
  55. extern char win_comment[];
  56.  
  57. extern char DialogTitle[];
  58.  
  59. /****************************************************************************
  60.  
  61.     FUNCTION: About(HWND, unsigned, WORD, LONG)
  62.  
  63.     PURPOSE:  Processes messages for "About" dialog box
  64.  
  65.     MESSAGES:
  66.  
  67.         WM_INITDIALOG - initialize dialog box
  68.         WM_COMMAND    - Input received
  69.  
  70. ****************************************************************************/
  71.  
  72. BOOL FAR PASCAL About(hDlg, message, wParam, lParam)
  73. HWND hDlg;
  74. unsigned message;
  75. WORD wParam;
  76. LONG lParam;
  77. {
  78.  
  79. float temp;
  80. char tempname[40];
  81.  
  82.     switch (message) {
  83.  
  84.          case WM_KEYDOWN:
  85.              switch (wParam) {
  86.                  case VK_F1:
  87.                  /* F1, shifted F1 bring up the Help Index */
  88.                      WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  89.                      break;
  90.                  }
  91.  
  92.         case WM_INITDIALOG:
  93.             temp = win_release / 100.0;
  94.             sprintf(tempname,"Fractint for Windows - Vers %5.2f", temp);
  95.             SetDlgItemText(hDlg, ID_VERSION,tempname);
  96.             SetDlgItemText(hDlg, ID_COMMENT,win_comment);
  97.             return (TRUE);
  98.  
  99.         case WM_COMMAND:
  100.         if (wParam == IDOK
  101.                 || wParam == IDCANCEL) {
  102.                 EndDialog(hDlg, TRUE);
  103.                 return (TRUE);
  104.             }
  105.             break;
  106.     }
  107.     return (FALSE);
  108. }
  109.  
  110. /****************************************************************************
  111.  
  112.     FUNCTION: Status(HWND, unsigned, WORD, LONG)
  113.  
  114.     PURPOSE:  Processes messages for "Status" dialog box
  115.  
  116.     MESSAGES:
  117.  
  118.         WM_INITDIALOG - initialize dialog box
  119.         WM_COMMAND    - Input received
  120.  
  121. ****************************************************************************/
  122.  
  123. BOOL FAR PASCAL Status(hDlg, message, wParam, lParam)
  124. HWND hDlg;
  125. unsigned message;
  126. WORD wParam;
  127. LONG lParam;
  128. {
  129. char tempstring[100];
  130. int i, j;
  131.  
  132.     switch (message) {
  133.  
  134.         case WM_KEYDOWN:
  135.             switch (wParam) {
  136.                 case VK_F1:
  137.                 /* F1, shifted F1 bring up the Help Index */
  138.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  139.                     break;
  140.                 }
  141.  
  142.         case WM_INITDIALOG:
  143.             sprintf(tempstring,"fractal type: ");
  144.             strcat(tempstring, fractalspecific[fractype].name);
  145.             if (calc_status == 1)
  146.                 strcat(tempstring,"    (still being calculated)");
  147.             else
  148.                 strcat(tempstring,"    (interrupted/completed)");
  149.             /* ##### */
  150.             SetDlgItemText(hDlg, IDS_LINE1,tempstring);
  151.             if(fractalspecific[fractype].param[0][0] == 0)
  152.                 tempstring[0] = 0;
  153.             else
  154.                 sprintf(tempstring,"%-30.30s   %14.10f",
  155.                     fractalspecific[fractype].param[0], param[0]);
  156.             SetDlgItemText(hDlg, IDS_LINE2,tempstring);
  157.             if(fractalspecific[fractype].param[1][0] == 0)
  158.                 tempstring[0] = 0;
  159.             else
  160.                 sprintf(tempstring,"%-30.30s   %14.10f",
  161.                     fractalspecific[fractype].param[1], param[1]);
  162.             SetDlgItemText(hDlg, IDS_LINE3,tempstring);
  163.             if(fractalspecific[fractype].param[2][0] == 0)
  164.                 tempstring[0] = 0;
  165.             else
  166.                 sprintf(tempstring,"%-30.30s   %14.10f",
  167.                     fractalspecific[fractype].param[2], param[2]);
  168.             SetDlgItemText(hDlg, IDS_LINE4,tempstring);
  169.             if(fractalspecific[fractype].param[3][0] == 0)
  170.                 tempstring[0] = 0;
  171.             else
  172.                 sprintf(tempstring,"%-30.30s   %14.10f",
  173.                     fractalspecific[fractype].param[3], param[3]);
  174.             SetDlgItemText(hDlg, IDS_LINE5,tempstring);
  175.             sprintf(tempstring,"Xmin:        %25.16f", xxmin);
  176.             SetDlgItemText(hDlg, IDS_LINE6,tempstring);
  177.             sprintf(tempstring,"Xmax:        %25.16f", xxmax);
  178.             SetDlgItemText(hDlg, IDS_LINE7,tempstring);
  179.             sprintf(tempstring,"Ymin:        %25.16f", yymin);
  180.             SetDlgItemText(hDlg, IDS_LINE8,tempstring);
  181.             sprintf(tempstring,"Ymax:        %25.16f", yymax);
  182.             SetDlgItemText(hDlg, IDS_LINE9,tempstring);
  183.             return (TRUE);
  184.  
  185.         case WM_COMMAND:
  186.         if (wParam == IDOK
  187.                 || wParam == IDCANCEL) {
  188.                 EndDialog(hDlg, TRUE);
  189.                 return (TRUE);
  190.             }
  191.             break;
  192.     }
  193.     return (FALSE);
  194. }
  195.  
  196. /****************************************************************************
  197.  
  198.     FUNCTION: SelectFractal(HWND, unsigned, WORD, LONG)
  199.  
  200.     PURPOSE: Initializes window data and registers window class
  201.  
  202. ****************************************************************************/
  203.  
  204. BOOL FAR PASCAL SelectFractal(hDlg, message, wParam, lParam)
  205. HWND hDlg;
  206. unsigned message;
  207. WORD wParam;
  208. LONG lParam;
  209. {
  210.  
  211.     int i;
  212.     int index;
  213.  
  214.     switch (message) {
  215.  
  216.         case WM_KEYDOWN:
  217.             switch (wParam) {
  218.                 case VK_F1:
  219.                 /* F1, shifted F1 bring up the Help Index */
  220.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  221.                     break;
  222.                 }
  223.  
  224.         case WM_INITDIALOG:
  225.             SetDlgItemText(hDlg, ID_LISTTITLE, DialogTitle);
  226.             for (i = 0; i < win_numchoices; i++) 
  227.                 SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_ADDSTRING,
  228.                     NULL, (LONG) (LPSTR) win_choices[i]);
  229.             SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_SETCURSEL,
  230.                 win_choicemade, 0L);
  231.             return (TRUE);
  232.             break;
  233.         
  234.         case WM_COMMAND:
  235.             switch (wParam) {
  236.                 case IDOK:
  237. okay:           
  238.                     index=SendDlgItemMessage(hDlg, IDM_FRACTAL,
  239.                         LB_GETCURSEL, 0, 0L);
  240.                     if (index == LB_ERR) {
  241.                         MessageBox(hDlg, "No Choice selected",
  242.                             "Select From a List", MB_OK | MB_ICONEXCLAMATION);
  243.                         break;
  244.                         }
  245.                     win_choicemade = index;
  246.                     EndDialog(hDlg, 1);
  247.                     break;
  248.                   
  249.                 case IDCANCEL:
  250.                     win_choicemade = -1;
  251.                     EndDialog(hDlg, 0);
  252.                     break;
  253.                     
  254.                 case IDM_FRACTAL:
  255.                     switch (HIWORD(lParam)) {
  256.                         case LBN_SELCHANGE:
  257.                             index = SendDlgItemMessage(hDlg, IDM_FRACTAL,
  258.                                 LB_GETCURSEL, 0, 0L);
  259.                             if (index == LB_ERR)
  260.                                 break;
  261.                             break;
  262.                          
  263.                        case LBN_DBLCLK:
  264.                             goto okay;
  265.                             break;
  266.                     }
  267.                 break;
  268.                 }
  269.         
  270.         }
  271.     return (FALSE);
  272. }
  273.  
  274. /****************************************************************************
  275.  
  276.     FUNCTION: SelectFracParams(HWND, unsigned, WORD, LONG)
  277.  
  278.     PURPOSE: Initializes window data and registers window class
  279.  
  280. ****************************************************************************/
  281.  
  282. BOOL FAR PASCAL SelectFracParams(hDlg, message, wParam, lParam)
  283. HWND hDlg;
  284. unsigned message;
  285. WORD wParam;
  286. LONG lParam;
  287. {
  288.  
  289.     int i;
  290.     int index;
  291.     char temp[30];
  292.  
  293.     switch (message) {
  294.  
  295.         case WM_KEYDOWN:
  296.             switch (wParam) {
  297.                 case VK_F1:
  298.                 /* F1, shifted F1 bring up the Help Index */
  299.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  300.                     break;
  301.                 }
  302.  
  303.         case WM_INITDIALOG:
  304.                 tempfractype = CurrentFractal;
  305.                 for (numparams = 0; numparams < 4; numparams++)
  306.                     if (fractalspecific[tempfractype].param[numparams][0] == 0)
  307.                         break;
  308.                 numtrig = (fractalspecific[tempfractype].flags >> 6) & 7;
  309.                 for (i = 0; i < 4; i++) {
  310.                     sprintf(temp,"%f",fractalspecific[tempfractype].paramvalue[i]);
  311.                     SetDlgItemText(hDlg, paramv[i], temp);
  312.                     SetDlgItemText(hDlg, paramt[i],"(n/a)");
  313.                     if (i < numparams)
  314.                        SetDlgItemText(hDlg, paramt[i],
  315.                            fractalspecific[tempfractype].param[i]);
  316.                     }
  317.                for(i=0; i<numtrig; i++) {
  318.                     SetDlgItemText(hDlg, paramt[i+numparams], trg[i]);
  319.                     SetDlgItemText(hDlg, paramv[i+numparams],
  320.                         trigfn[trigndx[i]].name);
  321.                     }
  322.             sprintf(temp,"%f",fractalspecific[tempfractype].xmin);
  323.         SetDlgItemText(hDlg, ID_FRACXMIN,   temp);
  324.             sprintf(temp,"%f",fractalspecific[tempfractype].xmax);
  325.         SetDlgItemText(hDlg, ID_FRACXMAX,   temp);
  326.             sprintf(temp,"%f",fractalspecific[tempfractype].ymin);
  327.         SetDlgItemText(hDlg, ID_FRACYMIN,   temp);
  328.             sprintf(temp,"%f",fractalspecific[tempfractype].ymax);
  329.         SetDlgItemText(hDlg, ID_FRACYMAX,   temp);
  330.         SetDlgItemText(hDlg, ID_FRACNAME,   fractalspecific[tempfractype].name);
  331.             return (TRUE);
  332.             break;
  333.         
  334.         case WM_COMMAND:
  335.             switch (wParam) {
  336.                 case IDOK:
  337.                     for (i = 0; i < 4; i++) {
  338.                         GetDlgItemText(hDlg, paramv[i], temp, 10);
  339.                         param[i] = atof(temp);
  340.                         }
  341.                     for (i = 0; i < numtrig; i++) {
  342.                         GetDlgItemText(hDlg, paramv[i+numparams], temp, 10);
  343.                         temp[4] = 0;
  344.                         if (temp[3] == 32) temp[3] = 0;
  345.                         set_trig_array(i, temp);
  346.                         }
  347.             GetDlgItemText(hDlg, ID_FRACXMIN  , temp, 10);
  348.             xxmin = atof(temp);
  349.             GetDlgItemText(hDlg, ID_FRACXMAX  , temp, 10);
  350.             xxmax = atof(temp);
  351.             GetDlgItemText(hDlg, ID_FRACYMIN  , temp, 10);
  352.             yymin = atof(temp);
  353.             GetDlgItemText(hDlg, ID_FRACYMAX  , temp, 10);
  354.             yymax = atof(temp);
  355.                     invert = 0;
  356.                     inversion[0] = inversion[1] = inversion[2] = 0;
  357.                     fractype = CurrentFractal;
  358.                     EndDialog(hDlg, 1);
  359.                     break;
  360.                   
  361.                 case IDCANCEL:
  362.                     EndDialog(hDlg, 0);
  363.                     break;
  364.  
  365.                 }
  366.         
  367.         }
  368.     return (FALSE);
  369. }
  370.  
  371. /****************************************************************************
  372.  
  373.     FUNCTION: SelectImage(HWND, unsigned, WORD, LONG)
  374.  
  375.     PURPOSE: Initializes window data and registers window class
  376.  
  377. ****************************************************************************/
  378.  
  379. BOOL FAR PASCAL SelectImage(hDlg, message, wParam, lParam)
  380. HWND hDlg;
  381. unsigned message;
  382. WORD wParam;
  383. LONG lParam;
  384. {
  385.  
  386.     int i;
  387.     int index;
  388.     char temp[15];
  389.  
  390.     switch (message) {
  391.  
  392.         case WM_KEYDOWN:
  393.             switch (wParam) {
  394.                 case VK_F1:
  395.                 /* F1, shifted F1 bring up the Help Index */
  396.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  397.                     break;
  398.                 }
  399.  
  400.         case WM_INITDIALOG:
  401.             tempcolors = colors;
  402.             if (tempcolors == 2)
  403.                 CheckDlgButton(hDlg, ID_ICOLORS1, 1);
  404.             else if (tempcolors == 16)
  405.                 CheckDlgButton(hDlg, ID_ICOLORS2, 1);
  406.             else
  407.                 CheckDlgButton(hDlg, ID_ICOLORS3, 1);
  408.             sprintf(temp,"%d",xdots);
  409.         SetDlgItemText(hDlg, ID_ISIZEX, temp);
  410.             sprintf(temp,"%d",ydots);
  411.         SetDlgItemText(hDlg, ID_ISIZEY, temp);
  412.         i = ID_ISIZE7;
  413.         if (xdots ==  200 && ydots == 150) i = ID_ISIZE1;
  414.         if (xdots ==  320 && ydots == 200) i = ID_ISIZE2;
  415.         if (xdots ==  640 && ydots == 350) i = ID_ISIZE3;
  416.         if (xdots ==  640 && ydots == 480) i = ID_ISIZE4;
  417.         if (xdots ==  800 && ydots == 600) i = ID_ISIZE5;
  418.         if (xdots == 1024 && ydots == 768) i = ID_ISIZE6;
  419.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, i);
  420.             return (TRUE);
  421.             break;
  422.         
  423.         case WM_COMMAND:
  424.             switch (wParam) {
  425.                 case IDOK:
  426.                     /* retrieve and validate the results */
  427.             GetDlgItemText(hDlg, ID_ISIZEX, temp, 10);
  428.             xdots = atoi(temp);
  429.             if (xdots < 50) xdots = 50;
  430.             if (xdots > 2048) xdots = 2048;
  431.             GetDlgItemText(hDlg, ID_ISIZEY, temp, 10);
  432.             ydots = atoi(temp);
  433.             if (ydots < 50) ydots = 50;
  434.             if (ydots > 2048) ydots = 2048;
  435.                     colors = tempcolors;
  436.                     /* allocate and lock a pixel array for the bitmap */
  437.                     /* problem, here - can't just RETURN!!! */
  438.                     tryagain:
  439.                     if (!clear_screen(0)) {
  440.                         MessageBox(hDlg, "Not Enough Memory for that sized Image",
  441.                             NULL, MB_OK | MB_ICONHAND);
  442.                         xdots = ydots = 100;
  443.                         goto tryagain;
  444.                         };
  445.                     ytop    = 0;        /* reset the zoom-box */
  446.                     ybottom = ydots-1;
  447.                     xleft   = 0;
  448.                     xright  = xdots-1;
  449.                     set_win_offset();
  450.                     zoomflag = TRUE;
  451.                     time_to_restart = 1;
  452.  
  453.                     ProgStr = Winfract;
  454.                     SaveIntParam(ImageWidthStr, xdots);
  455.                     SaveIntParam(ImageHeightStr, ydots);
  456.  
  457.                     EndDialog(hDlg, 1);
  458.                     break;
  459.                   
  460.                 case IDCANCEL:
  461.                     EndDialog(hDlg, 0);
  462.                     break;
  463.  
  464.                 case ID_ISIZE1:
  465.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE1);
  466.             SetDlgItemInt(hDlg, ID_ISIZEX, 200, TRUE);
  467.             SetDlgItemInt(hDlg, ID_ISIZEY, 150, TRUE);
  468.                     break;
  469.  
  470.                 case ID_ISIZE2:
  471.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE2);
  472.             SetDlgItemInt(hDlg, ID_ISIZEX, 320, TRUE);
  473.             SetDlgItemInt(hDlg, ID_ISIZEY, 200, TRUE);
  474.                     break;
  475.  
  476.                 case ID_ISIZE3:
  477.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE3);
  478.             SetDlgItemInt(hDlg, ID_ISIZEX, 640, TRUE);
  479.             SetDlgItemInt(hDlg, ID_ISIZEY, 350, TRUE);
  480.                     break;
  481.  
  482.                 case ID_ISIZE4:
  483.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE4);
  484.             SetDlgItemInt(hDlg, ID_ISIZEX, 640, TRUE);
  485.             SetDlgItemInt(hDlg, ID_ISIZEY, 480, TRUE);
  486.                     break;
  487.  
  488.                 case ID_ISIZE5:
  489.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE5);
  490.             SetDlgItemInt(hDlg, ID_ISIZEX, 800, TRUE);
  491.             SetDlgItemInt(hDlg, ID_ISIZEY, 600, TRUE);
  492.                     break;
  493.  
  494.                 case ID_ISIZE6:
  495.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE6);
  496.             SetDlgItemInt(hDlg, ID_ISIZEX, 1024, TRUE);
  497.             SetDlgItemInt(hDlg, ID_ISIZEY, 768, TRUE);
  498.                     break;
  499.  
  500.                 case ID_ISIZE7:
  501.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE7);
  502.                     break;
  503.  
  504.                 case ID_ICOLORS1:
  505.             CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS1);
  506.                     tempcolors = 2;
  507.                     break;
  508.  
  509.                 case ID_ICOLORS2:
  510.             CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS2);
  511.                     tempcolors = 16;
  512.                     break;
  513.  
  514.                 case ID_ICOLORS3:
  515.             CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS3);
  516.                     tempcolors = 256;
  517.                     break;
  518.  
  519.                 }
  520.         
  521.         }
  522.     return (FALSE);
  523. }
  524.  
  525. /****************************************************************************
  526.  
  527.     FUNCTION: SelectDoodads(HWND, unsigned, WORD, LONG)
  528.  
  529.     PURPOSE: Initializes window data and registers window class
  530.  
  531. ****************************************************************************/
  532.  
  533. BOOL FAR PASCAL SelectDoodads(hDlg, message, wParam, lParam)
  534. HWND hDlg;
  535. unsigned message;
  536. WORD wParam;
  537. LONG lParam;
  538. {
  539.  
  540.     int i;
  541.     int index;
  542.     char temp[80];
  543.     double win_invert;
  544.  
  545.     switch (message) {
  546.  
  547.         case WM_KEYDOWN:
  548.             switch (wParam) {
  549.                 case VK_F1:
  550.                 /* F1, shifted F1 bring up the Help Index */
  551.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  552.                     break;
  553.                 }
  554.  
  555.         case WM_INITDIALOG:
  556.             tempfloatflag = usr_floatflag;
  557.             tempstdcalcmode = usr_stdcalcmode;
  558.             if (tempstdcalcmode == '1')
  559.                 CheckDlgButton(hDlg, ID_PASS1, 1);
  560.             if (tempstdcalcmode == '2')
  561.                 CheckDlgButton(hDlg, ID_PASS2, 1);
  562.             if (tempstdcalcmode == 'g')
  563.                 CheckDlgButton(hDlg, ID_PASSS, 1);
  564.             if (tempstdcalcmode == 'b')
  565.                 CheckDlgButton(hDlg, ID_PASSB, 1);
  566.             if (tempfloatflag)
  567.                 CheckDlgButton(hDlg, ID_MATHF, 1);
  568.             else
  569.                 CheckDlgButton(hDlg, ID_MATHI, 1);
  570.             sprintf(temp,"%d",maxiter);
  571.         SetDlgItemText(hDlg, ID_MAXIT, temp);
  572.             sprintf(temp,"%d",biomorph);
  573.         SetDlgItemText(hDlg, ID_BIOMORPH, temp);
  574.             sprintf(temp,"%d",decomp);
  575.         SetDlgItemText(hDlg, ID_DECOMP, temp);
  576.             sprintf(temp,"%d",inside);
  577.         SetDlgItemText(hDlg, ID_INSIDE, temp);
  578.             sprintf(temp,"%d",outside);
  579.         SetDlgItemText(hDlg, ID_OUTSIDE, temp);
  580.         win_invert = -1;
  581.         if (invert != 0) {
  582.             win_invert = 0;
  583.             if (inversion[0] != AUTOINVERT)
  584.                 win_invert = inversion[0];
  585.             }
  586.             sprintf(temp,"%f",win_invert);
  587.         SetDlgItemText(hDlg, ID_INVERT, temp);
  588.             return (TRUE);
  589.             break;
  590.         
  591.         case WM_COMMAND:
  592.             switch (wParam) {
  593.                 case IDOK:
  594.                     /* retrieve and validate the results */
  595.                     usr_stdcalcmode = tempstdcalcmode;
  596.                     usr_floatflag = tempfloatflag;
  597.                     GetDlgItemText(hDlg, ID_MAXIT, temp, 10);
  598.                     maxiter = atoi(temp);
  599.                     if (maxiter < 10) maxiter = 10;
  600.                     if (maxiter > 32000) maxiter = 32000;
  601.                     GetDlgItemText(hDlg, ID_BIOMORPH, temp, 10);
  602.                     biomorph = atoi(temp);
  603.                     if (biomorph < 0) biomorph = -1;
  604.                     if (biomorph >= colors) biomorph = colors-1;
  605.                     GetDlgItemText(hDlg, ID_DECOMP, temp, 10);
  606.                     decomp = atoi(temp);
  607.                     if (decomp < 0) decomp = 0;
  608.                     if (decomp > 256) decomp = 256;
  609.                     GetDlgItemText(hDlg, ID_INSIDE, temp, 10);
  610.                     inside = atoi(temp);
  611.                     if (inside < 0) inside = 0;
  612.                     if (inside >= colors) inside = colors-1;
  613.                     GetDlgItemText(hDlg, ID_OUTSIDE, temp, 10);
  614.                     outside = atoi(temp);
  615.                     if (outside < 0) outside = -1;
  616.                     if (outside >= colors) outside = colors-1;
  617.                     GetDlgItemText(hDlg, ID_INVERT, temp, 10);
  618.                     win_invert = atof(temp);
  619.                     invert = 0;
  620.                     if (win_invert >= 0) {
  621.                         invert = 1;
  622.                         inversion[0] = AUTOINVERT;
  623.                         if (win_invert > 0)
  624.                             inversion[0] = win_invert;
  625.                         }
  626.                     time_to_restart = 1;
  627.                     EndDialog(hDlg, 1);
  628.                     break;
  629.                   
  630.                 case IDCANCEL:
  631.                     EndDialog(hDlg, 0);
  632.                     break;
  633.  
  634.                 case ID_PASS1:
  635.                     tempstdcalcmode = '1';
  636.                     CheckRadioButton(hDlg, ID_PASS1, ID_PASSB, ID_PASS1);
  637.                     break;
  638.  
  639.                 case ID_PASS2:
  640.                     tempstdcalcmode = '2';
  641.                     CheckRadioButton(hDlg, ID_PASS1, ID_PASSB, ID_PASS2);
  642.                     break;
  643.  
  644.                 case ID_PASSS:
  645.                     tempstdcalcmode = 'g';
  646.                     CheckRadioButton(hDlg, ID_PASS1, ID_PASSB, ID_PASSS);
  647.                     break;
  648.  
  649.                 case ID_PASSB:
  650.                     tempstdcalcmode = 'b';
  651.                     CheckRadioButton(hDlg, ID_PASS1, ID_PASSB, ID_PASSB);
  652.                     break;
  653.  
  654.                 case ID_MATHI:
  655.                     tempfloatflag = 0;
  656.                     CheckRadioButton(hDlg, ID_MATHI, ID_MATHF, ID_MATHI);
  657.                     break;
  658.  
  659.                 case ID_MATHF:
  660.                     tempfloatflag = 1;
  661.                     CheckRadioButton(hDlg, ID_MATHI, ID_MATHF, ID_MATHF);
  662.                     break;
  663.  
  664.                 }
  665.         
  666.         }
  667.     return (FALSE);
  668. }
  669.  
  670. /****************************************************************************
  671.  
  672.     FUNCTION: SelectCycle(HWND, unsigned, WORD, LONG)
  673.  
  674.     PURPOSE: Initializes window data and registers window class
  675.  
  676. ****************************************************************************/
  677.  
  678.  
  679. int win_cycledir = -1, win_cyclerand = 0, win_cyclefreq = 0;
  680. int win_tempcycle, win_tempcycledir, win_tempcyclerand, win_tempcyclefreq;
  681.  
  682. BOOL FAR PASCAL SelectCycle(hDlg, message, wParam, lParam)
  683. HWND hDlg;
  684. unsigned message;
  685. WORD wParam;
  686. LONG lParam;
  687. {
  688.  
  689.     int i;
  690.     int index;
  691.     char temp[80];
  692.  
  693.     switch (message) {
  694.  
  695.         case WM_KEYDOWN:
  696.             switch (wParam) {
  697.                 case VK_F1:
  698.                 /* F1, shifted F1 bring up the Help Index */
  699.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  700.                     break;
  701.                 }
  702.  
  703.         case WM_INITDIALOG:
  704.             win_tempcycle = time_to_cycle;
  705.             win_tempcycledir = win_cycledir;
  706.             win_tempcyclerand = win_cyclerand;
  707.             win_tempcyclefreq = win_cyclefreq;
  708.             if (win_tempcycle == 0)
  709.                 CheckDlgButton(hDlg, ID_CYCLEOFF, 1);
  710.             else
  711.                 CheckDlgButton(hDlg, ID_CYCLEON, 1);
  712.             if (win_tempcycledir == -1)
  713.                 CheckDlgButton(hDlg, ID_CYCLEOUT, 1);
  714.             else
  715.                 CheckDlgButton(hDlg, ID_CYCLEIN, 1);
  716.             if (win_tempcyclerand == 0)
  717.                 CheckDlgButton(hDlg, ID_CYCLESTAT, 1);
  718.             else
  719.                 CheckDlgButton(hDlg, ID_CYCLECHG, 1);
  720.             if (win_tempcyclefreq == 0)
  721.                 CheckDlgButton(hDlg, ID_CYCLELOW, 1);
  722.             else if (win_tempcyclefreq == 1)
  723.                 CheckDlgButton(hDlg, ID_CYCLEMED, 1);
  724.             else
  725.                 CheckDlgButton(hDlg, ID_CYCLEHIGH, 1);
  726.             return (TRUE);
  727.             break;
  728.         
  729.         case WM_COMMAND:
  730.             switch (wParam) {
  731.                 case IDOK:
  732.                     /* retrieve and validate the results */
  733.                     time_to_cycle = win_tempcycle;
  734.                     win_cycledir = win_tempcycledir;
  735.                     win_cyclerand = win_tempcyclerand;
  736.                     win_cyclefreq = win_tempcyclefreq;
  737.                     EndDialog(hDlg, 1);
  738.                     break;
  739.                   
  740.                 case IDCANCEL:
  741.                     EndDialog(hDlg, 0);
  742.                     break;
  743.  
  744.                 case ID_CYCLEOFF:
  745.                     win_tempcycle = 0;
  746.                     CheckRadioButton(hDlg, ID_CYCLEOFF, ID_CYCLEON, ID_CYCLEOFF);
  747.                     break;
  748.  
  749.                 case ID_CYCLEON:
  750.                     win_tempcycle = 1;
  751.                     CheckRadioButton(hDlg, ID_CYCLEOFF, ID_CYCLEON, ID_CYCLEON);
  752.                     break;
  753.  
  754.                 case ID_CYCLEOUT:
  755.                     win_tempcycledir = -1;
  756.                     CheckRadioButton(hDlg, ID_CYCLEOUT, ID_CYCLEIN, ID_CYCLEOUT);
  757.                     break;
  758.  
  759.                 case ID_CYCLEIN:
  760.                     win_tempcycledir = 1;
  761.                     CheckRadioButton(hDlg, ID_CYCLEOUT, ID_CYCLEIN, ID_CYCLEIN);
  762.                     break;
  763.  
  764.                 case ID_CYCLESTAT:
  765.                     win_tempcyclerand = 0;
  766.                     CheckRadioButton(hDlg, ID_CYCLESTAT, ID_CYCLECHG, ID_CYCLESTAT);
  767.                     break;
  768.  
  769.                 case ID_CYCLECHG:
  770.                     win_tempcyclerand = 1;
  771.                     CheckRadioButton(hDlg, ID_CYCLESTAT, ID_CYCLECHG, ID_CYCLECHG);
  772.                     break;
  773.  
  774.                 case ID_CYCLELOW:
  775.                     win_tempcyclefreq = 0;
  776.                     CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLELOW);
  777.                     break;
  778.  
  779.                 case ID_CYCLEMED:
  780.                     win_tempcyclefreq = 1;
  781.                     CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLEMED);
  782.                     break;
  783.  
  784.                 case ID_CYCLEHIGH:
  785.                     win_tempcyclefreq = 2;
  786.                     CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLEHIGH);
  787.                     break;
  788.  
  789.                 }
  790.         
  791.         }
  792.     return (FALSE);
  793. }
  794.  
  795. FARPROC lpSelectFullScreen;
  796.  
  797. extern HANDLE hInst;
  798.  
  799. int win_fullscreen_count;
  800. char * far win_fullscreen_prompts[20];
  801. char *win_fullscreen_heading;
  802. static struct fullscreenvalues win_fullscreen_values[20];
  803.  
  804. int fullscreen_prompt(    /* full-screen prompting routine */
  805.     char *hdg,        /* heading, lines separated by \n */
  806.     int numprompts,     /* there are this many prompts (max) */
  807.     char * far *prompts,    /* array of prompting pointers */
  808.     struct fullscreenvalues values[], /* array of values */
  809.     int options,        /* future use bits in case we need them */
  810.     int fkeymask        /* bit n on if Fn to cause return */
  811.     )
  812. {
  813. int i;
  814. int Return;
  815.  
  816. win_fullscreen_count = numprompts;
  817. win_fullscreen_heading = hdg;
  818. win_fullscreen_count = numprompts;
  819. for (i = 0; i < win_fullscreen_count; i++) {
  820.    win_fullscreen_prompts[i] = prompts[i]; 
  821.    win_fullscreen_values[i]  = values[i];
  822.    }
  823.  
  824. lpSelectFullScreen = MakeProcInstance(SelectFullScreen, hInst);
  825. Return = DialogBox(hInst, "SelectFullScreen", hwnd, lpSelectFullScreen);
  826. FreeProcInstance(lpSelectFullScreen);
  827.  
  828. if (Return) {
  829.     for (i = 0; i < win_fullscreen_count; i++) {
  830.         values[i] = win_fullscreen_values[i];
  831.     }
  832.     return(0);
  833.     }
  834.  
  835. return(-1);
  836. }
  837.  
  838. BOOL FAR PASCAL SelectFullScreen(hDlg, message, wParam, lParam)
  839. HWND hDlg;
  840. unsigned message;
  841. WORD wParam;
  842. LONG lParam;
  843. {
  844.  
  845.     int i;
  846.     char temp[80];
  847.  
  848.     switch (message) {
  849.  
  850.         case WM_KEYDOWN:
  851.             switch (wParam) {
  852.                 case VK_F1:
  853.                 /* F1, shifted F1 bring up the Help Index */
  854.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  855.                     break;
  856.                 }
  857.  
  858.         case WM_INITDIALOG:
  859.             SetDlgItemText(hDlg, ID_PROMPT00,win_fullscreen_heading);
  860.             for (i = 0; i < win_fullscreen_count; i++) {
  861.                 SetDlgItemText(hDlg, ID_PROMPT01+i,win_fullscreen_prompts[i]);
  862.                 if (win_fullscreen_values[i].type == 'd')
  863.                     sprintf(temp,"%10.5f",win_fullscreen_values[i].uval.dval);
  864.                 else
  865.                     strcpy(temp,win_fullscreen_values[i].uval.sval);
  866.                 SetDlgItemText(hDlg, ID_ANSWER01+i,temp);
  867.                 }
  868.             return (TRUE);
  869.             break;
  870.         
  871.         case WM_COMMAND:
  872.             switch (wParam) {
  873.                 case IDOK:
  874.                     for (i = 0; i < win_fullscreen_count; i++) {
  875.                         GetDlgItemText(hDlg, ID_ANSWER01+i , temp, 10);
  876.                         if (win_fullscreen_values[i].type == 'd')
  877.                             win_fullscreen_values[i].uval.dval = atof(temp);
  878.                         else
  879.                             strcpy(win_fullscreen_values[i].uval.sval,temp);
  880.                     }
  881.                     EndDialog(hDlg, 1);
  882.                     break;
  883.                   
  884.                 case IDCANCEL:
  885.                     EndDialog(hDlg, 0);
  886.                     break;
  887.  
  888.                 }
  889.         
  890.         }
  891.     return (FALSE);
  892. }
  893.  
  894.  
  895. extern int init3d[];
  896. extern int win_3dspherical;
  897. extern char preview, showbox;
  898. extern int previewfactor, glassestype, whichimage;
  899. extern int xtrans, ytrans, transparent[2], RANDOMIZE;
  900.  
  901. static int win_answers[20];
  902.  
  903. BOOL FAR PASCAL Select3D(hDlg, message, wParam, lParam)
  904. HWND hDlg;
  905. unsigned message;
  906. WORD wParam;
  907. LONG lParam;
  908. {
  909.  
  910.     int i, tempfill;
  911.     char temp[80];
  912.  
  913.     switch (message) {
  914.  
  915.         case WM_KEYDOWN:
  916.             switch (wParam) {
  917.                 case VK_F1:
  918.                 /* F1, shifted F1 bring up the Help Index */
  919.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  920.                     break;
  921.                 }
  922.  
  923.         case WM_INITDIALOG:
  924.             win_answers[0] = preview;
  925.             win_answers[1] = showbox;
  926.             win_answers[2] = SPHERE;
  927.             win_answers[3] = previewfactor;
  928.             win_answers[4] = glassestype;
  929.             win_answers[5] = FILLTYPE+1;
  930.             for (i = ID_PREVIEW; i <= ID_SPHERICAL; i++)
  931.                 CheckDlgButton(hDlg, i, win_answers[i-ID_PREVIEW]);
  932.             sprintf(temp,"%d",win_answers[3]);
  933.         SetDlgItemText(hDlg, ID_PREVIEWFACTOR, temp);
  934.             CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4,
  935.                 ID_STEREO1+win_answers[4]);
  936.             CheckRadioButton(hDlg, ID_FILL1, ID_FILL8,
  937.                 ID_FILL1+win_answers[5]);
  938.             return (TRUE);
  939.             break;
  940.         
  941.         case WM_COMMAND:
  942.             switch (wParam) {
  943.                 case IDOK:
  944.                     if(win_answers[2] != SPHERE) {
  945.                         SPHERE = win_answers[2];
  946.                         set_3d_defaults();
  947.                         }
  948.                     preview = win_answers[0];
  949.                     showbox = win_answers[1];
  950.                     SPHERE  = win_answers[2];
  951.                     GetDlgItemText(hDlg, ID_PREVIEWFACTOR, temp, 10);
  952.                     previewfactor = atoi(temp);
  953.                     glassestype = win_answers[4];
  954.                     FILLTYPE = win_answers[5]-1;
  955.                     win_3dspherical = SPHERE;
  956.                     if(previewfactor < 8)
  957.                        previewfactor = 8;
  958.                     if(previewfactor > 128)
  959.                        previewfactor = 128;
  960.                     if(glassestype < 0)
  961.                        glassestype = 0;
  962.                     if(glassestype > 3)
  963.                        glassestype = 3;
  964.                     whichimage = 0;
  965.                     if(glassestype)
  966.                        whichimage = 1;
  967.                     EndDialog(hDlg, 1);
  968.                     break;
  969.                     
  970.                 case ID_PREVIEW:
  971.                 case ID_SHOWBOX:
  972.                 case ID_SPHERICAL:
  973.                     i = wParam - ID_PREVIEW;
  974.                     win_answers[i] = 1 - win_answers[i];
  975.                     CheckDlgButton(hDlg, ID_PREVIEW + i, win_answers[i]);
  976.                     break;
  977.  
  978.                 case ID_FILL1:
  979.                 case ID_FILL2:
  980.                 case ID_FILL3:
  981.                 case ID_FILL4:
  982.                 case ID_FILL5:
  983.                 case ID_FILL6:
  984.                 case ID_FILL7:
  985.                 case ID_FILL8:
  986.                     i = wParam - ID_FILL1;
  987.                     win_answers[5] = i;
  988.                     CheckRadioButton(hDlg, ID_FILL1, ID_FILL8,
  989.                         ID_FILL1+win_answers[5]);
  990.                     break;
  991.  
  992.                 case ID_STEREO1:
  993.                 case ID_STEREO2:
  994.                 case ID_STEREO3:
  995.                 case ID_STEREO4:
  996.                     i = wParam - ID_STEREO1;
  997.                     win_answers[4] = i;
  998.                     CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4,
  999.                         ID_STEREO1+win_answers[4]);
  1000.                     break;
  1001.  
  1002.                 case IDCANCEL:
  1003.                     EndDialog(hDlg, 0);
  1004.                     break;
  1005.  
  1006.                 }
  1007.         
  1008.         }
  1009.     return (FALSE);
  1010. }
  1011.  
  1012. BOOL FAR PASCAL Select3DPlanar(hDlg, message, wParam, lParam)
  1013. HWND hDlg;
  1014. unsigned message;
  1015. WORD wParam;
  1016. LONG lParam;
  1017. {
  1018.  
  1019.     int i;
  1020.     char temp[80];
  1021.  
  1022.     switch (message) {
  1023.  
  1024.         case WM_KEYDOWN:
  1025.             switch (wParam) {
  1026.                 case VK_F1:
  1027.                 /* F1, shifted F1 bring up the Help Index */
  1028.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  1029.                     break;
  1030.                 }
  1031.  
  1032.         case WM_INITDIALOG:
  1033.             win_answers[0] = XROT;
  1034.             win_answers[1] = YROT;
  1035.             win_answers[2] = ZROT;
  1036.             win_answers[3] = XSCALE;
  1037.             win_answers[4] = YSCALE;
  1038.             win_answers[5] = ROUGH;
  1039.             win_answers[6] = WATERLINE;
  1040.             win_answers[7] = ZVIEWER;
  1041.             win_answers[8] = XSHIFT;
  1042.             win_answers[9] = YSHIFT;
  1043.             win_answers[10] = xtrans;
  1044.             win_answers[11] = ytrans;
  1045.             win_answers[12] = transparent[0];
  1046.             win_answers[13] = transparent[1];
  1047.             win_answers[14] = RANDOMIZE;
  1048.             for (i = 0; i < 15; i++) {
  1049.                 sprintf(temp,"%d", win_answers[i]);
  1050.                 SetDlgItemText(hDlg, ID_ANS1+i,temp);
  1051.                 }
  1052.             return (TRUE);
  1053.             break;
  1054.         
  1055.         case WM_COMMAND:
  1056.             switch (wParam) {
  1057.                 case IDOK:
  1058.                     for (i = 0; i < 15; i++) {
  1059.                         GetDlgItemText(hDlg, ID_ANS1+i, temp, 10);
  1060.                         win_answers[i] = atof(temp);
  1061.                         }
  1062.                     XROT =           win_answers[0];
  1063.                     YROT =           win_answers[1];
  1064.                     ZROT =           win_answers[2];
  1065.                     XSCALE =         win_answers[3];
  1066.                     YSCALE =         win_answers[4];
  1067.                     ROUGH =          win_answers[5];
  1068.                     WATERLINE =      win_answers[6];
  1069.                     ZVIEWER =        win_answers[7];
  1070.                     XSHIFT =         win_answers[8];
  1071.                     YSHIFT =         win_answers[9];
  1072.                     xtrans =         win_answers[10];
  1073.                     ytrans =         win_answers[11];
  1074.                     transparent[0] = win_answers[12];
  1075.                     transparent[1] = win_answers[13];
  1076.                     RANDOMIZE =      win_answers[14];
  1077.                     if (RANDOMIZE >= 7) RANDOMIZE = 7;
  1078.                     if (RANDOMIZE <= 0) RANDOMIZE = 0;
  1079.                     EndDialog(hDlg, 1);
  1080.                     break;
  1081.                   
  1082.                 case IDCANCEL:
  1083.                     EndDialog(hDlg, 0);
  1084.                     break;
  1085.  
  1086.                 }
  1087.         
  1088.         }
  1089.     return (FALSE);
  1090. }
  1091.  
  1092. BOOL FAR PASCAL Select3DSpherical(hDlg, message, wParam, lParam)
  1093. HWND hDlg;
  1094. unsigned message;
  1095. WORD wParam;
  1096. LONG lParam;
  1097. {
  1098.  
  1099.     int i;
  1100.     char temp[80];
  1101.  
  1102.     switch (message) {
  1103.  
  1104.         case WM_KEYDOWN:
  1105.             switch (wParam) {
  1106.                 case VK_F1:
  1107.                 /* F1, shifted F1 bring up the Help Index */
  1108.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  1109.                     break;
  1110.                 }
  1111.  
  1112.         case WM_INITDIALOG:
  1113.             win_answers[0] = XROT;
  1114.             win_answers[1] = YROT;
  1115.             win_answers[2] = ZROT;
  1116.             win_answers[3] = XSCALE;
  1117.             win_answers[4] = YSCALE;
  1118.             win_answers[5] = ROUGH;
  1119.             win_answers[6] = WATERLINE;
  1120.             win_answers[7] = ZVIEWER;
  1121.             win_answers[8] = XSHIFT;
  1122.             win_answers[9] = YSHIFT;
  1123.             win_answers[10] = xtrans;
  1124.             win_answers[11] = ytrans;
  1125.             win_answers[12] = transparent[0];
  1126.             win_answers[13] = transparent[1];
  1127.             win_answers[14] = RANDOMIZE;
  1128.             for (i = 0; i < 15; i++) {
  1129.                 sprintf(temp,"%d", win_answers[i]);
  1130.                 SetDlgItemText(hDlg, ID_ANS1+i,temp);
  1131.                 }
  1132.             return (TRUE);
  1133.             break;
  1134.         
  1135.         case WM_COMMAND:
  1136.             switch (wParam) {
  1137.                 case IDOK:
  1138.                     for (i = 0; i < 15; i++) {
  1139.                         GetDlgItemText(hDlg, ID_ANS1+i, temp, 10);
  1140.                         win_answers[i] = atof(temp);
  1141.                         }
  1142.                     XROT =           win_answers[0];
  1143.                     YROT =           win_answers[1];
  1144.                     ZROT =           win_answers[2];
  1145.                     XSCALE =         win_answers[3];
  1146.                     YSCALE =         win_answers[4];
  1147.                     ROUGH =          win_answers[5];
  1148.                     WATERLINE =      win_answers[6];
  1149.                     ZVIEWER =        win_answers[7];
  1150.                     XSHIFT =         win_answers[8];
  1151.                     YSHIFT =         win_answers[9];
  1152.                     xtrans =         win_answers[10];
  1153.                     ytrans =         win_answers[11];
  1154.                     transparent[0] = win_answers[12];
  1155.                     transparent[1] = win_answers[13];
  1156.                     RANDOMIZE =      win_answers[14];
  1157.                     if (RANDOMIZE >= 7) RANDOMIZE = 7;
  1158.                     if (RANDOMIZE <= 0) RANDOMIZE = 0;
  1159.                     EndDialog(hDlg, 1);
  1160.                     break;
  1161.                   
  1162.                 case IDCANCEL:
  1163.                     EndDialog(hDlg, 0);
  1164.                     break;
  1165.  
  1166.                 }
  1167.         
  1168.         }
  1169.     return (FALSE);
  1170. }
  1171.